﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Display.DialogUI {
    import flash.events.*;
    import Engine.Managers.*;
    import flash.display.*;
    import org.aswing.*;
    import Classes.*;
    import org.aswing.geom.*;
    import org.aswing.ext.*;
    import Display.aswingui.*;

    public class CrewCell extends JPanel implements GridListCell {

        protected var m_cellData:Object;
        protected var m_size:IntDimension;
        protected var m_factory:CrewCellFactory;
        protected var m_imagePanel:JPanel;
        protected var m_infoPanel:JPanel;

        public function CrewCell(_arg1:CrewCellFactory, _arg2:LayoutManager=null){
            this.m_factory = _arg1;
            super(_arg2);
        }
        protected function get bgAssetName():String{
            if ((this.m_cellData is String)){
                return (null);
            };
            return (this.m_cellData.bgAsset);
        }
        protected function get picUrl():String{
            if ((this.m_cellData is String)){
                return (null);
            };
            return (this.m_cellData.picUrl);
        }
        public function setGridListCellStatus(_arg1:GridList, _arg2:Boolean, _arg3:int):void{
            ASwingHelper.prepare(_arg1);
            var _local4:int = (_arg1.width / _arg1.getColumns());
            var _local5:int = (_arg1.height / _arg1.getRows());
            this.setPreferredSize(new IntDimension(_local4, _local5));
            this.setMaximumSize(new IntDimension(_local4, _local5));
            this.setMinimumSize(new IntDimension(_local4, _local5));
            ASwingHelper.prepare(this);
            ASwingHelper.prepare(_arg1);
            this.layoutCell();
        }
        public function setCellValue(_arg1):void{
            this.m_cellData = _arg1;
            this.buildCell();
        }
        public function getCellValue(){
            return (this.m_cellData);
        }
        public function getCellComponent():Component{
            return (this);
        }
        public function buildCell():void{
            this.initBackground();
            this.m_imagePanel = this.makeImagePanel();
            this.m_infoPanel = this.makeInfoPanel();
        }
        public function layoutCell():void{
            this.removeAll();
            ASwingHelper.prepare(this.m_imagePanel, this.m_infoPanel);
            this.m_imagePanel.setPreferredHeight(this.height);
            this.m_infoPanel.setPreferredSize(new IntDimension(((this.getPreferredWidth() - this.m_imagePanel.getPreferredWidth()) - 5), this.height));
            this.appendAll(this.m_imagePanel, this.m_infoPanel);
            ASwingHelper.prepare(this);
        }
        protected function initBackground():void{
            var _local1:DisplayObject;
            var _local2:MarginBackground;
            if (this.bgAssetName){
                _local1 = (new (this.m_factory.assets[this.bgAssetName])() as DisplayObject);
                _local2 = new MarginBackground(_local1, new Insets(0, 0, 0, 0));
                this.setBackgroundDecorator(_local2);
                this.m_size = new IntDimension(_local1.width, _local1.height);
                this.setMinimumSize(this.m_size);
                this.setPreferredSize(this.m_size);
                this.setMaximumSize(this.m_size);
            };
        }
        protected function makeImagePanel():JPanel{
            var asset:* = null;
            var image:* = null;
            var container:* = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.CENTER);
            asset = (new EmbeddedArt.hud_no_profile_pic() as DisplayObject);
            image = new Sprite();
            image.addChild(asset);
            var imageContainer:* = new AssetPane(image);
            ASwingHelper.setEasyBorder(imageContainer, 2, 0, 0, 5);
            ASwingHelper.prepare(imageContainer);
            if (this.picUrl){
                LoadingManager.loadFromUrl(this.picUrl, {
                    priority:LoadingManager.PRIORITY_HIGH,
                    completeCallback:function (_arg1:Event):void{
                        image.removeChild(asset);
                        asset = (_arg1.target.content as DisplayObject);
                        image.addChild(asset);
                    }
                });
            };
            container.append(imageContainer);
            ASwingHelper.prepare(container);
            return (container);
        }
        protected function makeInfoPanel():JPanel{
            var _local1:JPanel = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.TOP);
            return (_local1);
        }

    }
}//package Display.DialogUI 
